#include "TileMap.h"
#include "Layer.h"


CTileMap::CTileMap(void)
{
}


CTileMap::~CTileMap(void)
{
	vector< CLayer* >::iterator layerIter = m_Layers.begin();
	for( ; layerIter != m_Layers.end(); ++layerIter )
	{
		delete (*layerIter);
		m_Layers.erase( layerIter-- );
	}
}


bool CTileMap::AddLayer( CLayer* pLayer )
{
	if( pLayer != nullptr )
	{
		m_Layers.push_back( pLayer );
		return true;
	}
	else 
		return false;

}


void CTileMap::RenderMap( void )
{
	vector< CLayer* >::iterator layerIter = m_Layers.begin();
	for( ; layerIter != m_Layers.end(); ++layerIter )
	{
		(*layerIter)->RenderLayer();
	}
}


void CTileMap::UpdateMap( float dCameraPosition )
{
	vector< CLayer* >::iterator layerIter = m_Layers.begin();
	for( ; layerIter != m_Layers.end(); ++layerIter )
	{
		(*layerIter)->RenderLayer();
	}
}

bool CTileMap::CheckCharacterCollision( CBaseObject* pOther )
{
	return m_Layers.back()->CheckCharacterCollision( pOther );
}
